/*
 * Account.java
 *
 */

package com.javacore.day3.deposit;

import java.util.Scanner;

/**
 * 
 * @author
 */
public class Account {
	static boolean isaccNumber = false;
	static boolean isbalance = false;

	/** Creates a new instance of Account */
	public Account() {
	}

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String[] args) {
		// Declaring the variables
		int accountNumber = 0;
		double accountBalance = 0;

		// Initializing the variables
		Scanner scan = new Scanner(System.in);
		System.out
				.println("Enter the details for the new Account to be created....");
		do {
			System.out.println("Enter the Account Number: ");
			String straccountNumber = scan.nextLine();
			try {
				accountNumber = Integer.parseInt(straccountNumber);
				isaccNumber = true;
			} catch (Exception ex) {
				System.out.println("Account number invalid!Please try again");
			}
		} while (!isaccNumber);
		do {
			System.out.println("Enter the Account Balance: ");
			try {
				String straccountBalance = scan.nextLine();
				accountBalance = Integer.parseInt(straccountBalance);
				isbalance = true;
			} catch (Exception ex) {
				System.out.println("Balance invalid!Please try again!");
			}
		} while (!isbalance);
		// Displaying the values of the variables.
		System.out.println("The details of the new account are:");
		System.out.printf("Account Number: %d", accountNumber);
		System.out.printf("\nAccount Balance: $%.2f", accountBalance);
	}
}